package com.wu.constant.Enum;

import com.wu.common.convertion.exception.ClientException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Cousin
 * @date 2025/1/10
 * @Description
 */
@AllArgsConstructor
@Getter
public enum TimeUnitEnum {
    SECOND("second", "秒"), MINUTE("minute", "分钟"), HOUR("hour", "小时"),
    DAY("day", "天"),MONTH("month","月"),YEAR("year","年");
    private final String name;
    private final String desc;
    public static TimeUnitEnum getByName(String name) {
        for (TimeUnitEnum e : TimeUnitEnum.values()) {
            if (e.getName().equalsIgnoreCase(name)) {
                return e;
            }
        }
        throw new ClientException("Unknown time unit");
    }


}
